Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package suggested git script with Python package #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joao-p-marques
Copy link

As suggested in acsone/git-aggregator#55

@sbidoul @yajo this solves the problem by using a pure Bash script. However, I still haven't found a way of making it optional on install... Any ideas?

Some notes on what was already explored:

  1. A Python script to replace the git command is not viable due to Python load times.
  2. setuptools allows you to define optional commands to be insatalled, but AFAIK only through entry_points, which is only meant for Python modules.
  3. I tried packaging a Python script that would only override git clone (git-clone) as that would not introduce more delays that autoshare itself and it would only affect the clone operation. However, even when I have git-clone in the path, git clone still redirects to the normal command. I guess it is one of those subcommands that can't be replaced...

@Tecnativa
TT32042

@sbidoul
Copy link
Member

sbidoul commented Oct 19, 2021

However, I still haven't found a way of making it optional on install... Any ideas?

The only idea I might have is to create a separate package with only the bash script and depend on it in an extra. But... meh.
Also I'm not sure of the status of setuptools scripts. I'd need to check.

@joao-p-marques
Copy link
Author

@sbidoul Maybe not the most elegant solution, but I just added the option to explicitly opt-in to the script replacement through a shell variable...

scripts/git Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
if [[ "$GIT_AUTOSHARE" == "1" && "$1" == "clone" ]]
then
shift
/usr/bin/git autoshare-clone "$@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to affect people with git in other paths.

Suggested change
/usr/bin/git autoshare-clone "$@"
"$0" autoshare-clone "$@"

shift
/usr/bin/git autoshare-clone "$@"
else
/usr/bin/git "$@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/usr/bin/git "$@"
"$0" "$@"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work I am afraid, as $0 (git) will resolve to the current script and cause a loop...

Copy link

@Tardo Tardo Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe shomething like

Suggested change
/usr/bin/git "$@"
${GIT_BIN:-/usr/bin/git} "$@"

??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants